<template>
	<view class="j_cont">
		<!-- 导航栏 -->
		<view class="j_top">
			<!-- 跳转图标 -->
			<view class="j_left_icon">
				<text @click="back">&lt;</text>
			</view>
			<!-- 标题 -->
			<view class="j_title">
				昵称
			</view>
			<!-- right -->
			<view class="j_ttip">
				<text @click="release">发布</text>
			</view>
		</view>
		<!-- 更改昵称 -->
		<view class="j_nickname">
			<u-form :model="form" ref="uForm">
				<u-form-item label="姓名">
					<u-input v-model="form.name" />
				</u-form-item>
			</u-form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: undefined,
				form: {
					name: '',
				},
			}
		},
		methods: {
			//返回上一级页面
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			//发布
			release() {
				this.$api.nameupMsg({
					id: this.id,
					nickname: this.form.name
				}).then(res => {
					this.form.name = ''
				})
			}
		},
		//获取你要更改数据的id
		onLoad(option) {
			this.id = option.id
		}

	}
</script>

<style lang="scss" scoped>
	.j_cont {
		width: 100%;
		height: 100vh;
		background: #F2F2F2;

		//导航栏
		.j_top {
			width: 100%;
			height: 80upx;
			background: white;
			padding: 0 20upx;
			box-sizing: border-box;
			line-height: 80upx;
			display: flex;

			//left
			.j_left_icon {
				width: 10%;
				height: 100%;

				font-size: 40upx;
				text-align: center;
			}

			//title
			.j_title {
				width: 70%;
				height: 100%;
				text-align: center;
			}

			//right
			.j_ttip {
				width: 20%;
				height: 100%;
				text-align: center;
				color: #FAAB34;
				font-size: 30upx;
			}
		}
	}

	//更改昵称
	.j_nickname {
		width: 100%;
		height: 110upx;
		background: white;
		margin-top: 40upx;
		padding: 0 20upx;
		box-sizing: border-box;
	}
</style>
